//
//  TXScrollView.m
//  Towerxi3
//
//  Created by MAC on 2021/5/8.
//

#import "TXScrollView.h"

@implementation TXScrollView

/**
 同时识别多个手势
 
 @param gestureRecognizer gestureRecognizer description
 @param otherGestureRecognizer otherGestureRecognizer description
 @return return value description
 */
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    
    if (self.contentOffset.x <= 0) {
        if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
            // 根据速度获取拖动方向
            CGPoint velocity = [(UIPanGestureRecognizer*)gestureRecognizer velocityInView:self];
            if (velocity.x > 0) {
                //手势向右滑动
                return YES;
            }
        }
    }

    if (self.contentOffset.x >= self.contentSize.width - SCWidth) {
        if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
            // 根据速度获取拖动方向
            CGPoint velocity = [(UIPanGestureRecognizer*)gestureRecognizer velocityInView:self];
            if (velocity.x < 0) {
                //手势向左滑动
                return YES;
            }
        }
    }

    return NO;
}

@end
